package com.wmlt.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.lang3.StringEscapeUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

/**
 * @description: 获取servlet的json字符串
 * @param:  
 * @return:  
 * @author liyuxiang
 * @date: 2021/3/26 10:16 上午
 */ 
public class GetRequestJsonUtils {
    public static JSONObject getRequestJsonObject(HttpServletResponse response, HttpServletRequest request) throws IOException {
        InputStreamReader insr = new InputStreamReader(request.getInputStream(), "utf-8");
        String result = "";
        int respInt = insr.read();
        while (respInt != -1) {
            result += (char) respInt;
            respInt = insr.read();
        }
        JSONObject jsonObject = JSONObject.parseObject(result);

    return jsonObject;
}

}